package com.lfz.rabbit.direct;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import static com.lfz.RabbitConfig.DIRECT_QUEUE_NAME;

@Component
public class DirectServer {

    @RabbitHandler
    @RabbitListener(queues = DIRECT_QUEUE_NAME)
    public void process(String message) {
        // int millis = (int) (Math.random() * 2 * 1000);
        int millis = 5 * 1000;
        try {
            Thread.sleep(millis);
        } catch (InterruptedException e) {
        }
        System.out.println(message + " sleep for " + millis + " ms");
    }

}
